#ifndef __SLAB_BLOCK_H__
#define __SLAB_BLOCK_H__

#include "Block.hpp"
#include "IPaintableBlock.hpp"

namespace PocketSurvival
{
    // 半砖方块
    class SlabBlock : public Block, public IPaintableBlock
    {
	private:
		int32_t m_fullBlockIndex = -1;

    public:
		SlabBlock(int32_t fullBlockIndex);
		virtual bool isFaceTransparent(int32_t face, int32_t value) override;

        virtual void getCreativeValues(std::vector<int32_t> &blockVec) override;
        virtual void getDropValues(int32_t oldValue, int32_t newValue, int32_t toolLevel, std::vector<BlockDropValue> &dropValues) override;
    
        virtual BlockPlacementData getPlacementValue(ComponentMiner *componentMiner, int32_t value, const TerrainRaycastResult &raycastResult) override;
        virtual const std::vector<BoundingBox> &getCustomCollisionBoxes(int32_t value) override;

        virtual int32_t getPaintColor(int32_t value) override;
        virtual int32_t paint(int32_t value, int32_t color) override;

		static inline bool GetIsTop(int32_t contents);
		static inline int32_t SetIsTop(int32_t data, bool isTop);
        
        static inline int32_t GetColor(int32_t data);
        static inline int32_t SetColor(int32_t data, int32_t color);
		
    };

	inline bool SlabBlock::GetIsTop(int32_t data)
	{
		return (data & 1) != 0;
	}
	inline int32_t SlabBlock::SetIsTop(int32_t data, bool isTop)
	{
		return (data & -2) | (isTop ? 1 : 0);
	}
    inline int32_t SlabBlock::GetColor(int32_t data)
    {
		if ((data & 2) != 0)
		{
			return (data >> 2) & 0xF;
		}
		return -1;
    }
    inline int32_t SlabBlock::SetColor(int32_t data, int32_t color)
    {
		if (color != -1)
		{
			return (data & -63) | 2 | ((color & 0xF) << 2);
		}
		return data & -63;

    }
} // namespace PocketSurvival


#endif
